import java.util.ArrayList;
import java.util.List;

/**
 * @program: LeetCode
 * @description: LeetCode : 剑指 Offer II 079. 所有子集
 * @author: WXY
 * @create: 2023-01-04 20:28
 * @Version 1.0
 **/
public class Num_offer2_079_subsets {
    public static List<List<Integer>> list = new ArrayList<>();
    public static List<Integer> cur = new ArrayList<>();

    public static List<List<Integer>> subsets(int[] arr) {
        dfs(arr, 0);
        return list;
    }

    private static void dfs(int[] arr, int index) {
        list.add(new ArrayList<>(cur));
        for (int i = index; i < arr.length; i++) {
            cur.add(arr[i]);
            dfs(arr, i + 1);
            cur.remove(cur.size() - 1);
        }
    }


    public static void main(String[] args) {
        int[] arr = {1, 2, 3};
        List<List<Integer>> subsets = subsets(arr);
        System.out.println(subsets);
    }
}
